Polish off the LTO branch
authorAlex Crichton <alex@alexcrichton.com>
Fri, 14 Nov 2014 16:49:01 +0000 (08:49 -0800)
committerAlex Crichton <alex@alexcrichton.com>
Mon, 17 Nov 2014 18:17:56 +0000 (10:17 -0800)
Cargo.lock
Cargo.toml
src/cargo/core/manifest.rs
src/cargo/ops/cargo_rustc/mod.rs
src/doc/manifest.md
tests/test_cargo_compile.rs

index b48ba2225740e9a2545ac34427043c294fd0dd30..8db34ac779b34b024ac39151e79aaceece1655ee 100644 (file)
@@ -11,6 +11,7 @@ dependencies = [
  "registry 0.0.1-pre",
  "semver 0.1.0 (git+https://github.com/rust-lang/semver)",
  "tar 0.0.1 (git+https://github.com/alexcrichton/tar-rs)",
+ "time 0.0.1 (git+https://github.com/rust-lang/time)",
  "toml 0.1.0 (git+https://github.com/alexcrichton/toml-rs)",
  "url 0.1.0 (git+https://github.com/servo/rust-url)",
 ]
@@ -92,9 +93,10 @@ source = "git+https://github.com/alexcrichton/gcc-rs#f23b4ba15348508b9ac557fc7ee
 [[package]]
 name = "git2"
 version = "0.0.1"
-source = "git+https://github.com/alexcrichton/git2-rs#847a4902f3e0971c394ac3f35995e49a774b275a"
+source = "git+https://github.com/alexcrichton/git2-rs#afec995029fae2d1eedf4d635b2131080b5b196d"
 dependencies = [
  "libgit2-sys 0.0.1 (git+https://github.com/alexcrichton/git2-rs)",
+ "time 0.0.1 (git+https://github.com/rust-lang/time)",
  "url 0.1.0 (git+https://github.com/servo/rust-url)",
 ]
 
@@ -111,7 +113,7 @@ source = "git+https://github.com/carllerche/hamcrest-rust.git#998036d000095f72c8
 [[package]]
 name = "libgit2-sys"
 version = "0.0.1"
-source = "git+https://github.com/alexcrichton/git2-rs#847a4902f3e0971c394ac3f35995e49a774b275a"
+source = "git+https://github.com/alexcrichton/git2-rs#afec995029fae2d1eedf4d635b2131080b5b196d"
 dependencies = [
  "libssh2-sys 0.0.1 (git+https://github.com/alexcrichton/ssh2-rs)",
  "openssl-sys 0.0.1 (git+https://github.com/alexcrichton/openssl-sys)",
@@ -174,6 +176,14 @@ name = "tar"
 version = "0.0.1"
 source = "git+https://github.com/alexcrichton/tar-rs#47d2cc4b09e373a4cc7bee7c71ebf96b42ea620d"
 
+[[package]]
+name = "time"
+version = "0.0.1"
+source = "git+https://github.com/rust-lang/time#76698f52381a78cf654dbedfefd04c28a9806788"
+dependencies = [
+ "gcc 0.0.1 (git+https://github.com/alexcrichton/gcc-rs)",
+]
+
 [[package]]
 name = "toml"
 version = "0.1.0"
index b3f3f7a980213733856383d161485fbd058f858c..f36405f84b73eb48bb502c9538eb7c0a85982125 100644 (file)
@@ -39,6 +39,9 @@ git = "https://github.com/alexcrichton/git2-rs"
 [dependencies.glob]
 git = "https://github.com/rust-lang/glob"
 
+[dependencies.time]
+git = "https://github.com/rust-lang/time"
+
 [dependencies.registry]
 path = "src/registry"
 
index 0e96a8d7b0f73f2cd0f51c9e89bb0f329fd9ead4..aa220227c9d89c080e01f02245be87d6da532dcb 100644 (file)
@@ -162,7 +162,6 @@ impl Profile {
         Profile {
             env: "compile".to_string(), // run in the default environment only
             opt_level: 0,
-            lto: false,
             debug: true,
             .. Profile::default()
         }
@@ -182,7 +181,6 @@ impl Profile {
         Profile {
             env: "bench".to_string(),
             opt_level: 3,
-            lto: false,
             test: true,
             dest: Some("release".to_string()),
             .. Profile::default()
@@ -193,7 +191,6 @@ impl Profile {
         Profile {
             env: "release".to_string(),
             opt_level: 3,
-            lto: false,
             dest: Some("release".to_string()),
             .. Profile::default()
         }
index ebecb321a2f693c4eb89d039a872dbfe2347b0ff..f9168c06539cc59a3aca91d7f9bcac944bb054e3 100644 (file)
@@ -579,12 +579,11 @@ fn build_base_args(cx: &Context,
     if profile.get_opt_level() != 0 {
         cmd = cmd.arg("--opt-level").arg(profile.get_opt_level().to_string());
     }
-    if target.is_bin() && profile.get_lto() {
+    if (target.is_bin() || target.is_staticlib()) && profile.get_lto() {
         cmd = cmd.args(["-C", "lto"]);
     } else {
-        // @alexchrichton says that there may be some restrictions with LTO
-        // and codegen-units, so that we should only add codegen units when
-        // LTO is not used.
+        // There are some restrictions with LTO and codegen-units, so we
+        // only add codegen units when LTO is not used.
         match profile.get_codegen_units() {
             Some(n) => cmd = cmd.arg("-C").arg(format!("codegen-units={}", n)),
             None => {},
index 757183370d087eb32f9e249ccc81d0c2ce98ad97..41aaeb4f82614a6ce4382d61d781f0271a507941 100644 (file)
@@ -142,30 +142,35 @@ along with the defaults for each profile.
 opt-level = 0  # Controls the --opt-level the compiler builds with
 debug = true   # Controls whether the compiler passes -g or `--cfg ndebug`
 rpath = false  # Controls whether the compiler passes `-C rpath`
+lto = false    # Controls `-C lto` for binaries and staticlibs
 
 # The release profile, used for `cargo build --release`
 [profile.release]
 opt-level = 3
 debug = false
 rpath = false
+lto = false
 
 # The testing profile, used for `cargo test`
 [profile.test]
 opt-level = 0
 debug = true
 rpath = false
+lto = false
 
 # The benchmarking profile, used for `cargo bench`
 [profile.bench]
 opt-level = 3
 debug = false
 rpath = false
+lto = false
 
 # The documentation profile, used for `cargo doc`
 [profile.doc]
 opt-level = 0
 debug = true
 rpath = false
+lto = false
 ```
 
 # The `[features]` Section
@@ -187,7 +192,7 @@ name = "awesome"
 
 # The "default" set of optional packages. Most people will
 # want to use these packages, but they are strictly optional
-default = ["jquery", "uglifier"]
+default = ["jquery", "uglifier", "session"]
 
 # The "secure-password" feature depends on the bcrypt package.
 # This aliasing will allow people to talk about the feature in
index 43c696a98f2088b98da13fc6fafbff3e1d2f420b..64af6f2c9766a4115511edefc7d8c7d14eeef509 100644 (file)
@@ -740,20 +740,22 @@ test!(lto_build {
             name = "test"
             version = "0.0.0"
             authors = []
+
+            [profile.release]
             lto = true
         "#)
         .file("src/main.rs", "fn main() {}");
-    assert_that(p.cargo_process("build").arg("-v"),
+    assert_that(p.cargo_process("build").arg("-v").arg("--release"),
                 execs().with_status(0).with_stdout(format!("\
 {compiling} test v0.0.0 ({url})
-{running} `rustc {dir}{sep}src{sep}lib.rs --crate-name test --crate-type bin -g \
+{running} `rustc {dir}{sep}src{sep}main.rs --crate-name test --crate-type bin \
+        --opt-level 3 \
         -C lto \
-        -C metadata=[..] \
-        -C extra-filename=-[..] \
-        --out-dir {dir}{sep}target \
+        --cfg ndebug \
+        --out-dir {dir}{sep}target{sep}release \
         --dep-info [..] \
-        -L {dir}{sep}target \
-        -L {dir}{sep}target{sep}deps`
+        -L {dir}{sep}target{sep}release \
+        -L {dir}{sep}target{sep}release{sep}deps`
 ",
 running = RUNNING, compiling = COMPILING, sep = path::SEP,
 dir = p.root().display(),